package com.whu.waterworks.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


import com.opensymphony.xwork2.ActionSupport;
import com.whu.waterworks.dto.GisStationData;
import com.whu.waterworks.model.Realtimedata;
import com.whu.waterworks.model.Stationnumposition;
import com.whu.waterworks.service.DataService;
import com.whu.waterworks.service.StationnumpositionService;

public class GisRealStationDataAction extends ActionSupport {
	/**
	 * 
	 */
	final Logger logger = LoggerFactory.getLogger(GisRealStationDataAction.class);
	private static final long serialVersionUID = -1306791172160885531L;
	private String codes;//水厂编码
	private StationnumpositionService stationnumpositionService;
	private DataService dataService;
	private List<GisStationData> list;
	
    
    

	public String getCodes() {
		return codes;
	}

	public void setCodes(String codes) {
		this.codes = codes;
	}

	public StationnumpositionService getStationnumpositionService() {
		return stationnumpositionService;
	}

	public void setStationnumpositionService(
			StationnumpositionService stationnumpositionService) {
		this.stationnumpositionService = stationnumpositionService;
	}

	public DataService getDataService() {
		return dataService;
	}

	public void setDataService(DataService dataService) {
		this.dataService = dataService;
	}
    

	public List<GisStationData> getList() {
		return list;
	}

	public void setList(List<GisStationData> list) {
		this.list = list;
	}

	public String getAllStationData()
	{
		list= new ArrayList<>();
		System.out.println(codes);
        String[] codeArray =codes.split(",");
        for(String code : codeArray)
        {
        	System.out.println();
			GisStationData data = new GisStationData();
			List<Realtimedata> realtimedatas = dataService.getAllRealTimeDataById(code.trim());
				if(realtimedatas!=null && realtimedatas.size()>0)
				{
					data.setCode(code.trim());
					//每个站点的所有类型数据
					for(Realtimedata realtimedata:realtimedatas)
					{
						if(realtimedata.getId().getType().contains("流量"))
						{
							data.setLiuliang(realtimedata.getValue());
						}
						else if(realtimedata.getId().getType().contains("压力"))
						{
							data.setYali(realtimedata.getValue());
						}
						else if(realtimedata.getId().getType().contains("浊度"))
						{
							data.setZhuodu(realtimedata.getValue());
						}
						else if(realtimedata.getId().getType().contains("余氯"))
						{
							data.setYulv(realtimedata.getValue());
						}
					}
				   list.add(data);
				}
        }
		return SUCCESS;
	}
	
}
